package com.xiaohe66.web.gateway.http.im;

import com.xiaohe66.common.value.R;
import com.xiaohe66.web.application.im.ImUserAppService;
import com.xiaohe66.web.application.im.bo.ImUserUploadKeyBo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaohe
 * @since 2023.09.07 16:39
 */
@RestController
@RequestMapping("/im/user")
@RequiredArgsConstructor
public class ImUserController {

    private final ImUserAppService imUserAppService;

    @PutMapping("/key")
    public R<Void> uploadKey(@RequestBody ImUserUploadKeyBo bo) {
        imUserAppService.uploadPublicKey(bo);
        return R.ok();
    }

    @GetMapping("/current")
    public R<Object> currentUserInfo() {
        return R.ok(imUserAppService.currentUserInfo());
    }

    @GetMapping
    public R<Object> listAll() {
        return R.ok(imUserAppService.listAll());
    }
}
